package com.cookor.poi.modules.phy.util;

import java.util.ArrayDeque;

public class DequeUtil {
  public static volatile ArrayDeque<Integer> deque1_A = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque2_A = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque3_A = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque4_A = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque5_A = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque1_B = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque2_B = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque3_B = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque4_B = new ArrayDeque<>();
  
  public static volatile ArrayDeque<Integer> deque5_B = new ArrayDeque<>();
  
  public static void resetDeque() {
    deque1_A = new ArrayDeque<>();
    deque2_A = new ArrayDeque<>();
    deque3_A = new ArrayDeque<>();
    deque4_A = new ArrayDeque<>();
    deque5_A = new ArrayDeque<>();
    deque1_B = new ArrayDeque<>();
    deque2_B = new ArrayDeque<>();
    deque3_B = new ArrayDeque<>();
    deque4_B = new ArrayDeque<>();
    deque5_B = new ArrayDeque<>();
  }
  
  public static void addA(Integer index, Integer value) {
    if (index.intValue() == 1) {
      deque1_A.offer(value);
    } else if (index.intValue() == 2) {
      deque2_A.offer(value);
    } else if (index.intValue() == 3) {
      deque3_A.offer(value);
    } else if (index.intValue() == 4) {
      deque4_A.offer(value);
    } else if (index.intValue() == 5) {
      deque5_A.offer(value);
    } 
  }
  
  public static Integer pushA(Integer index) {
    if (index.intValue() == 1)
      return deque1_A.poll(); 
    if (index.intValue() == 2)
      return deque2_A.poll(); 
    if (index.intValue() == 3)
      return deque3_A.poll(); 
    if (index.intValue() == 4)
      return deque4_A.poll(); 
    if (index.intValue() == 5)
      return deque5_A.poll(); 
    return null;
  }
  
  public static Integer Asize(Integer index) {
    if (index.intValue() == 1)
      return Integer.valueOf(deque1_A.size()); 
    if (index.intValue() == 2)
      return Integer.valueOf(deque2_A.size()); 
    if (index.intValue() == 3)
      return Integer.valueOf(deque3_A.size()); 
    if (index.intValue() == 4)
      return Integer.valueOf(deque4_A.size()); 
    if (index.intValue() == 5)
      return Integer.valueOf(deque5_A.size()); 
    return Integer.valueOf(0);
  }
  
  public static void addB(Integer index, Integer value) {
    if (index.intValue() == 1) {
      deque1_B.offer(value);
    } else if (index.intValue() == 2) {
      deque2_B.offer(value);
    } else if (index.intValue() == 3) {
      deque3_B.offer(value);
    } else if (index.intValue() == 4) {
      deque4_B.offer(value);
    } else if (index.intValue() == 5) {
      deque5_B.offer(value);
    } 
  }
  
  public static Integer pushB(Integer index) {
    if (index.intValue() == 1)
      return deque1_B.poll(); 
    if (index.intValue() == 2)
      return deque2_B.poll(); 
    if (index.intValue() == 3)
      return deque3_B.poll(); 
    if (index.intValue() == 4)
      return deque4_B.poll(); 
    if (index.intValue() == 5)
      return deque5_B.poll(); 
    return null;
  }
  
  public static Integer Bsize(Integer index) {
    if (index.intValue() == 1)
      return Integer.valueOf(deque1_B.size()); 
    if (index.intValue() == 2)
      return Integer.valueOf(deque2_B.size()); 
    if (index.intValue() == 3)
      return Integer.valueOf(deque3_B.size()); 
    if (index.intValue() == 4)
      return Integer.valueOf(deque4_B.size()); 
    if (index.intValue() == 5)
      return Integer.valueOf(deque5_B.size()); 
    return Integer.valueOf(0);
  }
}
